/* 网格容器 */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 16px;
    background: #fafafa;
    border-radius: 12px;
    transition: all 0.3s ease;
}

/* 网格项 */
.checkbox-item {
    position: relative;
    padding: 10px 14px;
    border-radius: 8px;
    background: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f0f0f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
}

.checkbox-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(24, 144, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.checkbox-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: #40a9ff;
}

.checkbox-item:hover::before {
    opacity: 1;
}

.checkbox-item:active {
    transform: translateY(0);
}

/* 选中状态 */
.checkbox-item.checked {
    background: #e6f7ff;
    border-color: #1890ff;
    box-shadow: 0 0 0 1px #1890ff;
}

.checkbox-item.checked::before {
    background: linear-gradient(135deg, rgba(24, 144, 255, 0.15), rgba(24, 144, 255, 0.05));
    opacity: 1;
}

/* 复选框内容 */
.checkbox-content {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

/* 选项图标 */
.option-icon {
    font-size: 16px;
    color: #1890ff;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-item:hover .option-icon {
    transform: scale(1.1) rotate(-5deg);
    color: #40a9ff;
}

.checkbox-item.checked .option-icon {
    transform: scale(1.1);
    color: #096dd9;
}

/* Ant Design 组件样式覆盖 */
:deep(.ant-checkbox-wrapper) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    font-size: 14px;
    display: flex;
    align-items: center;
}

:deep(.ant-checkbox) {
    top: 0;
}

:deep(.ant-checkbox + span) {
    padding-left: 8px;
    padding-right: 4px;
    transition: all 0.3s ease;
}

:deep(.ant-checkbox-checked + span) {
    color: #1890ff;
    font-weight: 500;
}

:deep(.ant-checkbox-wrapper:hover .ant-checkbox-inner),
:deep(.ant-checkbox:hover .ant-checkbox-inner) {
    border-color: #40a9ff;
}

:deep(.ant-checkbox-checked .ant-checkbox-inner) {
    background-color: #1890ff;
    border-color: #1890ff;
}

:deep(.ant-checkbox-checked::after) {
    border-color: #1890ff;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .checkbox-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
        padding: 12px;
    }

    .checkbox-item {
        padding: 8px 12px;
    }

    .option-icon {
        font-size: 14px;
    }

    :deep(.ant-checkbox-wrapper) {
        font-size: 13px;
    }
}

/* 动画效果 */
@keyframes checkboxPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.2);
    }

    100% {
        box-shadow: 0 0 0 8px rgba(24, 144, 255, 0);
    }
}

.checkbox-item.checked {
    animation: checkboxPulse 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 加载状态 */
.checkbox-item.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
    overflow: hidden;
}

.checkbox-item.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* 禁用状态 */
.checkbox-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* 暗色主题支持 */
[data-theme="dark"] .checkbox-grid {
    background: #141414;
}

[data-theme="dark"] .checkbox-item {
    background: #1f1f1f;
    border-color: #303030;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .checkbox-item:hover {
    border-color: #177ddc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .checkbox-item.checked {
    background: #111d2c;
    border-color: #177ddc;
    box-shadow: 0 0 0 1px #177ddc;
}

[data-theme="dark"] .checkbox-item::before {
    background: linear-gradient(135deg, rgba(23, 125, 220, 0.1), transparent);
}

[data-theme="dark"] .option-icon {
    color: #177ddc;
}

[data-theme="dark"] .checkbox-item:hover .option-icon {
    color: #40a9ff;
}

[data-theme="dark"] :deep(.ant-checkbox-checked + span) {
    color: #177ddc;
}

/* 高对比度模式支持 */
@media (forced-colors: active) {
    .checkbox-item {
        border: 2px solid ButtonBorder;
    }

    .checkbox-item.checked {
        border-color: Highlight;
    }
}